﻿(function () {
	window.User = Spine.Model.sub();
	window.User.configure("User", "id", "name", "level", "money", "game_friends", 'invited_friends', 'levels_fast_completed');
	window.User.extend({
		getUser: function (id) {
			return this.select(function (user) { return user.id == id; })[0];
		},
		getCurrentUser: function () {
			var currentUser = new window.User({
				id: 1, 
				name: "Трактор Комбайнович", 
				level: 34, 
				money: 300, 
				game_friends: [2, 3, 4],
				invited_friends: [2, 3],
				levels_fast_completed: 1
			});
			currentUser.save();
			return currentUser;
		}
	});
	window.User.include({
		getGameFriends: function () {
			var ids = this.game_friends;
			return this.game_friends.map(function (id) {
				return window.User.getUser(id);
			});
		}
	});
	var user2 = new window.User({
		id: 2, 
		name: "Мойдодыр Петрович", 
		level: 3, 
		money: 100, 
		game_friends: [1, 3, 4],
		invited_friends: [1],
		levels_fast_completed: 0
	});
	user2.save();
	var user3 = new window.User({
		id: 3, 
		name: "Георгий Карбинович", 
		level: 4, 
		money: 200, 
		game_friends: [1],
		invited_friends: [4],
		levels_fast_completed: 1
	});
	user3.save();
	var user4 = new window.User({
		id: 4, 
		name: "Трактор Иванов", 
		level: 1, 
		money: 0, 
		game_friends: [1, 4],
		invited_friends: [],
		levels_fast_completed: 3
	});
	user4.save();
})();